package com.itheima.method.method3;

public class Demo4Method {
    public static void main(String[] args) {
        getCount(20);
    }

    public static int getCount(int month) {
        if (month < 1) {
            System.out.println("参数有误");
            return -1;
        }
        if (month == 1 || month == 2) {
            return 1;
        } else {
            int arr[] = new int[month];
            arr[0] = 1;
            arr[1] = 1;
            for (int i = 2; i < arr.length; i++) {
                arr[i] = arr[i - 1] + arr[i - 2];
            }
            System.out.println("兔子的对数:" + " " + arr[arr.length - 1]);
            return arr[arr.length - 1];
        }

    }
}
